<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <link href="${staticPath!}/resources/static/style/images/favicon.ico" rel="shortcut icon" type="image/x-icon"/>
  <#include "/common/csslib.html">
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <!-- login begin -->
        <div align="center" id="login-panel" style="margin-top:60px">
          <!-- panel content -->
          <div align="center" class="panel" id="panel-content" id="login-form">
            <form action="/login/userRegister" class="form-condensed" id="registerForm" method="post">
              <table class="table table-form" style="width:400px">
                <tbody>
                <tr>
                  <th class="text-right">账号：</th>
                  <td>
                    <input class="form-control col-sm-2" name="account" onblur="RegisterManager.checkAccount()"
                           placeholder="请输入账号"
                           required="required" type="text"/>
                  </td>
                  <td>
                    <div>
                      <span class="required" id="accountTips">*</span>
                    </div>
                  </td>
                </tr>
                <tr>
                  <th class="text-right">密码：</th>
                  <td>
                    <input class="form-control col-sm-2" name="password" placeholder="请输入密码" required="required"
                           type="password"/>
                  </td>
                  <td>
                    <div class="col-sm-1 col-md-1 col-xs-1">
                      <span class="required">*</span>
                    </div>
                  </td>
                </tr>
                <tr>
                  <th class="text-right">请再次输入密码：</th>
                  <td>
                    <input class="form-control col-sm-2" name="rePassword" placeholder="请再次输入密码" required="required"
                           type="password"/>
                  </td>
                  <td>
                    <div class="col-sm-1 col-md-1 col-xs-1">
                      <span class="required">*</span>
                    </div>
                  </td>
                </tr>
                <tr>
                  <th class="text-right">手机号码：</th>
                  <td>
                    <input class="form-control col-sm-2" isTel="true" name="mobile" placeholder="请输入手机号码"
                           required="required"
                           type="text"/>
                  </td>
                  <td>
                    <div class="col-sm-1 col-md-1 col-xs-1">
                      <span class="required">*</span>
                    </div>
                  </td>
                </tr>
                <tr>
                  <th class="text-right">邮箱：</th>
                  <td>
                    <input class="form-control col-sm-2" email="true" name="email" placeholder="请输入邮箱"
                           required="required"
                           type="text"/>
                  </td>
                  <td>
                    <div class="col-sm-1 col-md-1 col-xs-1">
                      <span class="required">*</span>
                    </div>
                  </td>
                </tr>
                <tr>
                  <th></th>
                  <td>
                    <button class="btn btn-primary" id="submitBtn" name="submitBtn"
                            onclick="RegisterManager.userRegist()"
                            type="button">注册
                    </button>
                    <button class="btn btn-primary" id="backBtn" name="bankBtn" onclick="RegisterManager.toLogin()"
                            type="button">返回
                    </button>
                  </td>
                </tr>
                </tbody>
              </table>
            </form>
          </div>
          <div class="panel-foot" id="panel-foot">
          </div>
        </div>
        <!-- login end -->
      </div>
    </div>
  </div>
</div>
<#include "/common/jslib.html">
<script type="text/javascript">
    $(function () {
        RegisterManager = {
            init: function () {
            },
            toLogin: function () {
                window.location.href = "/login/to-login";
            },
            //用户注册
            userRegist: function () {
                var password = $("#password").val();
                var repassword = $("#repassword").val();
                if (password != repassword) {
                    Jmts.alert("两次密码输入不一致，请重新输入");
                    return false;
                }
                Jmts.ajaxSubmit(document.getElementById("registerForm"), function (result) {
                    if (result.success) {
                        Jmts.confirm("注册成功，是否跳到登录页面登录？", function () {
                            window.location.href = "/login/to-login";
                        });
                    } else {
                        Jmts.alert(result.msg);
                    }
                });
                return false;
            },
            checkAccount: function () {//校验账号
                var account = $("input[name='account']").val();
                var url = "/login/checkAccount";
                var data = {
                    account: account
                }
                Jmts.ajaxPost(url, data, function (result) {
                    if (result.success) {
                        $("#accountTips").html("*");
                    } else {
                        $("input[name='account']").val("");
                        $("#accountTips").html("账号已存在!");
                    }
                });
            }
        }
        RegisterManager.init();
        $("#registerForm").validate();
    });
</script>
</body>
</html>
